package com.manage.func.article.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.manage.base.dao.impl.BaseDaoImpl;
import com.manage.func.article.dao.IArticleDao;
import com.manage.func.article.model.ArticleBean;
import com.manage.func.article.model.ArticleCatalogBean;
import com.manage.func.article.model.ArticleCommentBean;
import com.manage.func.article.model.ArticleExpireBean;

@Repository("articleDao")
public class ArticleDaoImpl extends BaseDaoImpl<ArticleBean> implements IArticleDao {

	@Override
	public List<ArticleBean> selectArticleList(ArticleBean bean) {
		return getSqlSession().selectList("ArticleMapper.selectArticleList", bean);
	}

	@Override
	public List<ArticleCatalogBean> selectArticleCatalogList() {
		return getSqlSession().selectList("ArticleMapper.selectArticleCatalogList");
	}

	@Override
	public int insertArticle(ArticleBean queryBean) {
		return getSqlSession().insert("ArticleMapper.insertArticle", queryBean);
	}

	@Override
	public int updateArticle(ArticleBean queryBean) {
		return getSqlSession().update("ArticleMapper.updateArticle", queryBean);
	}

	@Override
	public int selectTotalCount(ArticleBean queryBean) {
		return getSqlSession().selectOne("ArticleMapper.selectTotalCount", queryBean);
	}

	@Override
	public int deleteArticle(ArticleBean queryBean) {
		return getSqlSession().delete("ArticleMapper.deleteArticle", queryBean);
	}

	@Override
	public List<ArticleExpireBean> expireSelect() {

		return getSqlSession().selectList("expireNewsCheck");

	}

	@Override
	public int expireUpdate(Long articleId) {

		return getSqlSession().update("expireNewsUpdate", articleId);
	}

	@Override
	public ArticleBean selectArticleById(ArticleBean bean) {
		return getSqlSession().selectOne("ArticleMapper.selectArticleById", bean);
	}

	@Override
	public List<ArticleCommentBean> selectArticleCommentListById(ArticleCommentBean bean) {
		return getSqlSession().selectList("ArticleMapper.selectArticleCommentListById", bean);
	}

	@Override
	public int selectArticleCommentCountById(ArticleCommentBean queryBean) {
		return getSqlSession().selectOne("ArticleMapper.selectArticleCommentCountById", queryBean);
	}

	@Override
	public int updateCommentStatus(ArticleCommentBean queryBean) {
		return getSqlSession().update("updateCommentStatus", queryBean);
	}

	@Override
	public void deleteTotalComment(ArticleCommentBean bean) {
		getSqlSession().delete("deleteTotalComment",bean);
		getSqlSession().update("updateCommontCount", bean);
	}

	@Override
	public void delCommont(ArticleCommentBean bean) {
		getSqlSession().delete("deleteCommentOne",bean);
		getSqlSession().update("updateCommontCountOne", bean);
	}

}
